home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 5 / 005.d81 / dos part 10 < prev    next >
Text File  |  2022-08-26  |  3KB  |  193 lines

  1.       Dos & Don'ts  --- Part 10
  2.  
  3.          by Joel Ellis Rea
  4. --------------------------------------
  5.  
  6.   To use a channel on the disk drive,
  7.  
  8. you must use BASIC's OPEN command.
  9.  
  10. The OPEN command wants three numeric
  11.  
  12. parameters and a string parameter.
  13.  
  14. eg: open6,8,6,"houses"
  15.  
  16.   The first parameter is the Logical
  17.  
  18. File Number, which is simply an
  19.  
  20. arbitrary number from 0 to 255 that
  21.  
  22. is used by your program to identify
  23.  
  24. the file from when you OPEN it until
  25.  
  26. you CLOSE it.  For now, avoid numbers
  27.  
  28. larger than 127.
  29.  
  30.   The second parameter is the First
  31.  
  32. Address, which is actually the device
  33.  
  34. number.  For disk drives, the First
  35.  
  36. Address can be 8, 9, 10, or 11.  If
  37.  
  38. you have only one drive unit, it is
  39.  
  40. almost always First Address #8.
  41.  
  42.   The third parameter is the Second
  43.  
  44. Address.  It is a number from 0 to 31
  45.  
  46. which passes additional information to
  47.  
  48. the device specified in the First
  49.  
  50. Address.  In the case of disk drives,
  51.  
  52. the Second Address is the channel
  53.  
  54. number, plain and simple!
  55.  
  56.   So, if we wanted to OPEN the
  57.  
  58. Command/Error channel of drive unit 8
  59.  
  60. as file #10, the command would be:
  61.  
  62.  
  63.   OPEN 10, 8, 15
  64.  
  65. where 15 means channel #15, the
  66.  
  67. Command/Error channel.
  68.  
  69.  
  70.   The OPEN command can also take a
  71.  
  72. string parameter after the three
  73.  
  74. numbers.  This string is passed to the
  75.  
  76. device immediately, with a special
  77.  
  78. signal attached.  For devices such as
  79.  
  80. printers, the string is simply
  81.  
  82. considered to be the same as any other
  83.  
  84. data.  The disk drive, however, uses
  85.  
  86. it as a file name when a data channel
  87.  
  88. is OPENed.  If the Command/Error
  89.  
  90. channel is OPENed, the string can
  91.  
  92. contain a command.  One command that
  93.  
  94. is good to use is the Initialize
  95.  
  96. command, which verifies that a
  97.  
  98. Commodore 1541-format disk is in the
  99.  
  100. drive.  So, a useful command to open
  101.  
  102. the Command/Error channel might be:
  103.  
  104.  
  105.   OPEN 15, 8, 15, "I0"
  106.  
  107.  
  108. This time we used a Logical File
  109.  
  110. Number of 15 to help remind us that
  111.  
  112. this is, indeed, the Command/Error
  113.  
  114. channel.
  115.  
  116.  
  117.   Now that the channel is OPEN, what
  118.  
  119. can you do with it?  Well, any DOS
  120.  
  121. Maintenance command can be sent to the
  122.  
  123. disk drive via this channel.  By using
  124.  
  125. the PRINT# command, data is sent to
  126.  
  127. the file specified by the Logical
  128.  
  129. File Number followint the '#' in the
  130.  
  131. PRINT# command.  That means you can
  132.  
  133. send most normal Wedge commands using
  134.  
  135. OPEN15,8,15 and PRINT#15.  Except for
  136.  
  137. @$ (Directory), @ (Disk Status, [more
  138.  
  139. later]), @#n (to change the First
  140.  
  141. Address used by the Wedge to 'n'), and
  142.  
  143. @Q (to disable the Wedge).
  144.  
  145.   For example, we can programmatically
  146.  
  147. scratch all files whose name starts
  148.  
  149. with the letter 'Z' by executing a
  150.  
  151. command such as  PRINT #15, "S:Z*"
  152.  
  153. Notice that the Wedge's '@' is not
  154.  
  155. included in the PRINT# 15 command.
  156.  
  157. The command above, of course, assumes
  158.  
  159. that the Command/Error channel has
  160.  
  161. been previously OPENed as Logical File
  162.  
  163. number 15.
  164.  
  165.  
  166.   By INPUTting from the Command/Error
  167.  
  168. channel (with an INPUT# command), the
  169.  
  170. Disk Drive Status can be obtained.
  171.  
  172. The following command:
  173.  
  174.  
  175.   INPUT #15, ER%, ER$, ET%, EB%
  176.  
  177.  
  178. will assign the Error Code Number to
  179.  
  180. ER%, the Error Message itself to ER$,
  181.  
  182. the Track on which the error occurred
  183.  
  184. to ET%, and the Block number to EB%.
  185.  
  186. This is a very important command.  It
  187.  
  188. allows the program to act on errors
  189.  
  190. that may happen during data access.
  191.  
  192. ------- Continued in Part 11 ---------
  193.